package com.dongdongshop.consume;

import com.alibaba.fastjson.JSONObject;
import com.dongdongshop.service.ItemPageServiceI;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


@Service
@RocketMQMessageListener(topic = "CCTV",consumerGroup = "my-group") //频道,主题
public class ItemRockMq implements RocketMQListener<String> {


    @Autowired
    private ItemPageServiceI itemPageServiceI;

    @Override
    public void onMessage(String s) {
        //截取字符串
        String idss=s.replaceAll("'","");
        String[] split = idss.split(",");
        //遍历出所有选中的ID
        for (String goodsId : split) {
            itemPageServiceI.itemPage(Long.parseLong(goodsId));
        }

    }
}
